n = int(input())
board = [list(input()) for _ in range(n)]
directions = [(-1, -1), (-1, 1), (1, -1), (1, 1)]
